package top.kaoshanji.p1ch01c.exception;

import java.util.ArrayList;
import java.util.List;

/**
 * 基础异常
 * author kaoshanji
 * ^_^
 * create time 2024/12/22 17:15
 */
public class BaseRuntimeException extends RuntimeException {

    private List<Throwable> exceptions = new ArrayList<>();

    public BaseRuntimeException() {}

    public BaseRuntimeException(String message) {
        super(message);
    }

    public BaseRuntimeException(Throwable cause) {
        super(cause);
    }

    public BaseRuntimeException(String message, Throwable cause) {
        super(message, cause);
    }

    public boolean isThrownRequired() {
        return exceptions.size() > 0;
    }

    public void addException(Throwable exception) {

        if (exception != null) {
            exceptions.add(exception);
        }
    }
}
